using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CustomControls
{
    public partial class FlexBorderPanel : Panel
    {
       //[Description("Change the starting color of gradient background"), Category("Gradient"), Browsable(true)]
       // private Color _GradientStart;
       // public Color GradientStart
       // {
       //     get
       //     {
       //         return _GradientStart;
       //     }
       //     set
       //     {
       //         _GradientStart = value;
       //         Invalidate();
       //     }
       // }
        
       // [Description("Change the end color of gradient background"), Category("Gradient"), Browsable(true)]
       // private Color _GradientEnd;
       // public Color GradientEnd
       // {
       //     get
       //     {
       //         return _GradientEnd;
       //     }
       //     set
       //     {
       //         _GradientEnd = value;
       //         Invalidate();
       //     }
       // }

       // [Description("Change the background gradient direction"), Category("Gradient"), Browsable(true)]
       // private LinearGradientMode _GradientDirection;
       // public LinearGradientMode GradientDirection
       // {
       //     get
       //     {
       //         return _GradientDirection;
       //     }
       //     set
       //     {
       //         _GradientDirection = value;
       //         Invalidate();
       //     }
       // }

        [Bindable(true), Category("Border Options"), DefaultValue(System.Windows.Forms.Border3DSide.All),
        Description("Specifies the sides of the panel to apply a three-dimensional border to.")]
        private System.Windows.Forms.Border3DSide borderSide;
        public System.Windows.Forms.Border3DSide BorderSide
        {
            get { return this.borderSide; }
            set
            {
                if (this.borderSide != value)
                {
                    this.borderSide = value;
                    this.Invalidate();
                }
            }
        }

		[Bindable(true), Category("Border Options"), DefaultValue(System.Windows.Forms.Border3DStyle.Etched),
		Description("Specifies the style of the three-dimensional border.")]
        private System.Windows.Forms.Border3DStyle border3DStyle;
		public System.Windows.Forms.Border3DStyle Border3DStyle
		{
			get { return this.border3DStyle; }
			set
			{
				if( this.border3DStyle != value )
				{
					this.border3DStyle = value;
					this.Invalidate();
				}
			}
		}

        public FlexBorderPanel()
        {
            // Set default values for our control's properties
            this.borderSide = System.Windows.Forms.Border3DSide.All;
            this.border3DStyle = System.Windows.Forms.Border3DStyle.Etched;

            // Set the base control BorderStyle to None, as there's no need for multiple borders
            base.BorderStyle = System.Windows.Forms.BorderStyle.None;


            //this._GradientStart = Color.FromKnownColor(KnownColor.Control);
            //this._GradientEnd = Color.FromKnownColor(KnownColor.Control);
            //this._GradientDirection = LinearGradientMode.Vertical;
        }

        protected override void OnResize(EventArgs e)
        {
            Invalidate();
            base.OnResize(e);
        }
		protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
		{
            if (Width == 0 || Height == 0) return;
            base.OnPaint(e);
            //if (BackgroundImage != null)
            //    base.OnPaint(e);
            //else
            //{
            //    base.OnPaint(e);
            //    LinearGradientBrush brsh = new LinearGradientBrush(new Rectangle(0, 0, Width,
            //                                        Height), _GradientStart,
            //                                        _GradientEnd, _GradientDirection);
            //    e.Graphics.FillRectangle(brsh, 0, 0, Width, Height);
            //}

			// allow normal control painting to occur first
			//base.OnPaint(e);

			// add our custom border
			System.Windows.Forms.ControlPaint.DrawBorder3D (
				e.Graphics,
				this.ClientRectangle,
				this.border3DStyle,
				this.borderSide );
		}
    }
}
